<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge,chrome=1">
    <meta name="author" content="王佳佳">
    <title></title>
    <style>
        *
        {
            box-sizing: border-box;
        }
        body
        {
            margin: 0;
            height: 2000px;
        }
        .main
        {
            width: 100%;
            height: 30px;
            border-bottom: 1px solid gainsboro;
            font-size: 15px;
        }
        .main aside
        {
            height: 30px;
            line-height: 30px;
            width: 750px;
            /* border: 1px solid; */
            margin-left: calc(100% - 750px);
        }
        .main aside div
        {
            display: inline-block;
            margin-left: 13px;
        }
        .main aside div a
        {
            color: #222;
        }
        .span
        {
             padding-right: 15px; 
             border-right: 1px solid gainsboro; 
             height: 15px;
             line-height: 15px;
        } 



        .head
        {
             /* border: 1px solid;  */
            width: 1000px;
            height: 85px;
            margin-top: 30px;
            margin: 30px auto;
        }
        .head-one
        {
            /* border: 1px solid; */
            width: 950px;
            height: 60px;
             line-height: 60px; 
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        .head-one img
        {
            width: 135px;
            height: 45px;
        }
        .sousuo,#blue
        {
            display: inline-block;
            color: white;
        }
        .sousuo
        {
            width: 550px;
            height: 40px;
            border: 1px solid gray;
        }
        #blue
        {
            width: 105px;
            height: 40px;
            line-height: 40px; 
            text-align: center;
            background-color: #3388ff;
            position: relative;
            margin-left: -5px;
            bottom: -1px;
        }
        .head-one a
        {
            color: black;
        }
        


        .head-two
        {
            /* border: 1px solid;  */
            width: 950px;
            height: 25px;
        }
        .radio
        {
            font-size: 12px;
            color: gray;
            padding-left: 138px;
        }


        .nav
        {
            width: 100%;
            height: 40px;
            background-color: #01204F;
        }
        .nav aside
        {
            width: 1000px;
            margin: auto;
        }
        .nav aside div
        {
            /* height: 40px;
            line-height: 40px; */
            display: inline-block;
            color: white;
            font-size: 15px;
            padding: 10px 10px;
            cursor: pointer;
        }
        .active
        {
            background-color: red;
        }
        .special
        {
            width: 60px;
            height: 60px;
            line-height: 60px;
            text-align: center;
            background-color: skyblue;
            font-size: 30px;
            position: absolute;
            top: 1500px;
            cursor: pointer;
        }
    </style>
</head>
<body>
    <section class="main">
        <aside>
        <div><a href="">网页</a></div>
        <div><a href="">新闻</a></div>
        <div><a href="">贴吧</a></div>
        <div><a href="">知道</a></div>
        <div><a href="">音乐</a></div>
        <div><a href="">图片</a></div>
        <div><a href="">视频</a></div>
        <div><a href="">地图</a></div>
        <div class="span"><a href="">文库</a></div>
        <div><a href="">百度首页</a></div>
        <div><a href="">登录</a></div>
        <div><a href="">注册</a></div>
        <div><a href="">百度新闻客户端</a></div>
        </aside>
    </section>

    <section class="head">
        <aside class="head-one">
            <img src="logo.png" alt="">
            <div>
                <input class="sousuo" type="text">
                <div id="blue">百度一下</div>
            </div>
            <div><a href="">帮助</a></div>
            <div><a href="">高级搜索</a></div>
            <div><a href="">设置</a></div>
        </aside>
        <aside class="head-two">
            <div class="radio">
                <!-- 单选框 -->
                <input type="radio" name="sex" value="" checked>新闻全文
                <input type="radio" name="sex" value="">新闻标题
            </div>
        </aside>
    </section>

    <section class="nav">
        <aside>
            <div class="active">首页</div>
            <div>百家号</div>
            <div>国内</div>
            <div>国际</div>
            <div>军事</div>
            <div>社会</div>
            <div>财经</div>
            <div>娱乐</div>
            <div>体育</div>
            <div>互联网</div>
            <div>科技</div>
            <div>游戏</div>
            <div>时尚</div>
            <div>女人</div>
            <div>汽车</div>
            <div>个性推荐</div>
            <div>更多</div>
        </aside>
    </section>

    <section class="special">
        &#8593;
    </section>


</body>
</html>

<script>
    var nav = document.querySelector('.nav');
    window.onscroll = function()
    {
        var scrollTop = document.scrollingElement.scrollTop;
        console.log(scrollTop);
        if(scrollTop > 180)
        {
            nav.style.top = '0';
            nav.style.position = 'fixed';
        }
        else
        {
            nav.style.position = '';
        }
    }


    var divs = document.querySelector('.nav').querySelector('aside').querySelectorAll('div');
    document.querySelectorAll('div');
    for(var i = 0; i < divs.length; i++)
        {
            divs[i].index = i;
            divs[i].onmouseover = function()
            {
                //触发事件之后，先将所有div标签的类名清空
                for(var i = 0; i < divs.length; i++)
                {
                    divs[i].className = '';
                }
                // console.log(this);
                //找到选中的div标签添加active类名
                this.className = 'active';
                divs[0].className = 'active';
            }
            divs[i].onmouseout = function()
            {
                this.className = '';
            }
        }


    var special = document.querySelector('.special');
    special.onclick = function()
    {
        document.scrollingElement.scrollTop = '0';
    }

</script>